<template>
  <div class="changepassword">
    <table class="tb" border="0" cellspacing="15" align="center">
      <tr>
        <td>手机号码:</td>
        <td colspan="3">
          <input type="text" id="tel" style="width: 300px;height: 30px" v-model="info.telephone">
        </td>
      </tr>
      <tr>
        <td>旧密码:</td>
        <td colspan="3">
          <input type="text" id="old_password" style="width: 300px;height: 30px" v-model="info.password">
        </td>
      </tr>
      <tr>
        <td>新密码:</td>
        <td colspan="3">
          <input type="text" id="new_password" style="width: 300px;height: 30px" v-model="info.new_password">
        </td>
      </tr>
      <tr>
        <td colspan="4">
          <button @click="btn_ok" value="" style="width: 80px;height: 30px;margin-left: 100px">确认修改</button>
          <input type="submit" value="取消" style="width: 80px;height: 30px;margin-left: 50px">
        </td>
      </tr>
    </table>
  </div>
</template>

<script>
    export default {
      name: "Viewrecord",
      data() {
        return {
          info: {
            telephone:'',
            password: '',
            new_password: '',
          },
          result:null,
          awesome:false,
        };
      },
      methods: {
        btn_ok:function()  {
          var this_=this;
          this_.$store.state.telephone=this_.info.telephone;
          this_.$store.state.password=this_.info.password;
          this_.$store.state.new_password=this_.info.new_password;



          this.$axios.post('http://127.0.0.1:8080/record/change_password', {
              "tel":  this_.$store.state.telephone,
              "password": this_.$store.state.password,
              "new_password":  this_.$store.state.new_password
          })
            .then(function (response) {
              this_.result=response.data.code
              if(this_.result &&this_.result==="1014"){
                this_.$message({
                  message: '修改成功',
                  type: 'success'
                });
              }
              else{
                this_.$message.error('修改失败');
              }
            })
            .catch(function (error) {
              console.log(error);
            });
        },
        created() {

        },
      }
    }
</script>

<style scoped>
  .changepassword{
    padding-top: -20px;
  }
  .tip{
    width: 758px;
    height: 60px;
    background: #79ffda;
    /*display: none;*/
  }
</style>
